package com.shujia.core

import org.apache.spark.rdd.RDD
import org.apache.spark.{SparkConf, SparkContext}

object Demo11Cartesian {
  def main(args: Array[String]): Unit = {

    // 创建Spark Context
    val conf: SparkConf = new SparkConf()
    conf.setAppName("Demo11Cartesian")
    conf.setMaster("local")

    val sc: SparkContext = new SparkContext(conf)

    val rdd1: RDD[(String, String)] = sc.parallelize(List(("001", "zs"), ("002", "ls"), ("003", "ww")))
    val rdd2: RDD[(String, String)] = sc.parallelize(List(("001", "10"), ("002", "20")))

    // 笛卡尔积 转换算子
    rdd1
      .cartesian(rdd2)
      .foreach(println)

  }

}
